﻿<%@ Page Language="C#" MasterPageFile="~/templates/MasterpageAdmin.Master" AutoEventWireup="true" CodeBehind="Level.aspx.cs" Inherits="QuanCafe.admin.Level" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Danh sach đối tác</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
      <!-- content-box-header --> 		
    <div class="content-box-header">					
        <h3>cấp Độ</h3>								
    </div> 
    <!-- End .content-box-header -->  
    <div class="content-box-content">
        <div class="notification attention png_bg" id="error_pnl" style="float: left;">
			<div>
                <asp:Label ID="lblError" runat="server" CssClass="label_error"></asp:Label>
                <asp:TextBox ID="txtLevelID" runat="server" Visible="false"></asp:TextBox>
			</div>
		</div>
        <div class="content-box-row">
            <fieldset>
                <div>
                    <div class="left required" style="width:20%;">
                        <span>Tên Cấp Độ</span>
                    </div>
                    <div class="left required">
                        <asp:TextBox ID="txtLevelName" runat="server" CssClass="text-input"></asp:TextBox>
                    </div> 
                </div>
                
                <div class="left required" style="width:90%;">
                    <span style="width:150px;">Mô tả cấp độ</span>                    
                    <asp:TextBox ID="txtLevelDesc" runat="server" CssClass="text-input" Width="79%" TextMode="MultiLine" Rows="5"></asp:TextBox>
                </div>
                <div class="left" style="width:5%;">
                    <small id="character_counter" style="float:left; font-style:italic; margin:4px 0 0 0;">0 kí tự</small>
                </div>
                <div>
                </div>            
            </fieldset>
        </div>
        <div class="content-box-row">
            <div class="button-row">
                <center>
                    <asp:Button ID="btnAddNew" runat="server" Text="Hũy bỏ" CssClass="button" 
                        onclick="btnAddNew_Click" />
                    <asp:Button ID="btnSave" runat="server" Text="Lưu" CssClass="button" OnClientClick="javascript: return CheckForm($('.label_error:eq(0)'))"
                        onclick="btnSave_Click" />
                    <asp:Button ID="btnCancel" runat="server" OnClientClick="javascript:return confirm('Có thật sự muốn xóa các tin này không?')" Text="Xóa" CssClass="button" 
                        onclick="btnCancel_Click" />
                </center>
            </div>
        </div>
        <div class="notification information png_bg" id="notice_pnl" style="float: left;">
            <div>
                <asp:Label ID="lblNotice" runat="server"></asp:Label>
            </div>
        </div>
        <div class="content-box-row">
            <asp:DataGrid CssClass="grid" ID="dtgLevel" Width="100%" 
                runat="server" AllowPaging="True" 
                AutoGenerateColumns="False" PagerStyle-Mode="NumericPages" PageSize="20"
                onitemcommand="dtgLevel_ItemCommand" 
                onpageindexchanged="dtgLevel_PageIndexChanged">
                <PagerStyle Mode="NumericPages" CssClass="gridPage"></PagerStyle>
                <HeaderStyle CssClass="gridHeader" />
                <FooterStyle CssClass="gridFooter" />
                <AlternatingItemStyle CssClass="gridAlter" />
                <ItemStyle CssClass="gridItem" />
                <Columns>
                    <asp:BoundColumn DataField="LevelID" Visible="false"></asp:BoundColumn>
                    <asp:TemplateColumn HeaderText="STT">
                        <HeaderStyle Width="5%" />
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                        <ItemTemplate>
                            <asp:LinkButton Runat="server" ID="btnID" CommandName="Edit">
                                <%# Container.ItemIndex + 1 + dtgLevel.PageSize * dtgLevel.CurrentPageIndex%>
                            </asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="Tên Cấp Độ">
                        <HeaderStyle Width="20%" />
                        <ItemStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:LinkButton Runat="server" ID="btnName" CommandName="Edit">
                                <%# DataBinder.Eval(Container, "DataItem.LevelName")%>
                            </asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateColumn>                     
                    <asp:TemplateColumn HeaderText="Mô tả">
                        <HeaderStyle Width="25%" />
                        <ItemStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <%# DataBinder.Eval(Container, "DataItem.LevelDesc")%>
                        </ItemTemplate>
                    </asp:TemplateColumn>                     
                    <asp:TemplateColumn HeaderText="Ngày đăng">
                        <HeaderStyle Width="10%" />
                        <ItemStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <%# DataBinder.Eval(Container, "DataItem.PostDate")%>
                        </ItemTemplate>
                    </asp:TemplateColumn>                      
                    <asp:TemplateColumn HeaderText="Người đăng">
				        <HeaderStyle Width="10%"></HeaderStyle>
					    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
					    <ItemTemplate>
					        <%# DataBinder.Eval(Container, "DataItem.Creator")%>
					    </ItemTemplate>
				    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="Kích hoạt">
                        <HeaderStyle Width="10%"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:ImageButton ID="btnActive" runat="server" Width="15px" Height="15px"
                                CommandArgument='<%# Eval("LevelID") %>' CommandName="activechange"   ImageUrl="~/Images/icons/btnOK.jpg" />                
                        </ItemTemplate>
                    </asp:TemplateColumn>
                   <asp:TemplateColumn HeaderText="Chọn">
	                    <HeaderStyle Width="20%" HorizontalAlign="Center"></HeaderStyle>
	                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
	                    <HeaderTemplate>
	                        <input type="checkbox" id="chkSelectAll" onclick="CheckAll($(this), '<%= dtgLevel.ClientID %>')" />
	                    </HeaderTemplate>
	                    <ItemTemplate>
	                        <span id='<%# DataBinder.Eval(Container, "DataItem.LevelID")%>'></span>
		                    <asp:CheckBox id="chkSelect" runat="server"></asp:CheckBox>
	                    </ItemTemplate> 
                    </asp:TemplateColumn>
                </Columns>
            </asp:DataGrid>
        </div>
    </div>
    <script type="text/javascript" language="javascript">
        if($.trim( $("#<%= this.lblError.ClientID %>").html() ) == "") $("#error_pnl").hide();
        if($.trim( $("#<%= this.lblNotice.ClientID %>").html() ) == "") $("#notice_pnl").hide();
    </script>
    <script type="text/javascript" language="javascript">        
        function CheckAll(obj, gridID)
        {
            var list_cate = $("#" + gridID);
            var isChecked = obj.is(":checked");
            var checkbox_list = $(":checkbox:[id != 'chkSelectAll']", list_cate);
            
            for(var i=0 ; i < checkbox_list.length ; i++)
            {
                checkbox_list.get(i).checked = isChecked;
            }
        }        
         
        $("#character_counter").html( $("#<%= this.txtLevelDesc.ClientID %>").get(0).value.length.toString() + " kí tự");
        $("#<%= this.txtLevelDesc.ClientID %>").keyup(function(event) {
            $("#character_counter").html( $(this).get(0).value.length.toString() + " kí tự");
        });
    </script>
</asp:Content>